package cn.tedu.rabbitmqboot.m3;


/*
 * 消费者自动启动,注册成为消费者
 * 自动开启监听队列中的消息
 * 不需要手动调用
 * @RabbitListener(queues = "helloworld")
 *   1. 在类上注解,需要 @RabbitHandler配合指定处理消息的方法
 *   2. 直接加载在方法上
 * */

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Consumer {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue, // 由服务器自动命名, false,ture,true
            exchange =@Exchange(name = "logs", declare = "false")  // 不重复定义这个虚拟机
    ))
    public void receive1(String msg) {
        System.out.println("消费者1收到: " + msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue, // 由服务器自动命名, false,ture,true
            exchange =@Exchange(name = "logs", declare = "false")  // 不重复定义这个虚拟机
    ))
    public void receive2(String msg) {
        System.out.println("消费者1收到: " + msg);
    }


}
